﻿<UserControl x:Class="Mengsk.ERP.App.Orders.OrderDetailUserControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300" 
             xmlns:myconvrters="clr-namespace:Mengsk.ERP.App.Orders"
             >
    
    <UserControl.Resources>
        <myconvrters:OrderFlagConverter x:Key="orderflagconvert"/>
        <myconvrters:OrderImageConverter x:Key="orderimageconvert"/>
        <myconvrters:ShopConverter x:Key="ordershopconvert"/>
        <myconvrters:OrderStateConverter x:Key="orderstateconvert"/>
    </UserControl.Resources>
    
    <ListBox Grid.Row="2" Name="lstOrders" ScrollViewer.CanContentScroll="False" >
        <ListBox.ItemContainerStyle>
            <Style TargetType="{x:Type ListBoxItem}">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type ListBoxItem}">
                            <GroupBox Margin="3" BorderThickness="3" BorderBrush="LightGreen">
                                <GroupBox.Header>
                                    <StackPanel Orientation="Horizontal">
                                        <TextBlock Margin="3" Text="{Binding Path=Shop,Converter={StaticResource ResourceKey=ordershopconvert}}" VerticalAlignment="Center"/>
                                        <TextBlock Margin="3" Text="-" VerticalAlignment="Center"/>
                                        <TextBox Margin="3" Text="{Binding Path=POPID}" VerticalAlignment="Center" IsReadOnly="True"/>
                                        <Image Source="{Binding Flag,Converter={StaticResource ResourceKey=orderflagconvert}}" Width="16" Height="16" Margin="3"/>
                                        <TextBlock Margin="3" VerticalAlignment="Center" Text="{Binding State,Converter={StaticResource ResourceKey=orderstateconvert}}" FontSize="14"/>
                                        <TextBlock Margin="3" VerticalAlignment="Center" Text="下单时间"/>
                                        <TextBlock Margin="3" VerticalAlignment="Center" Text="{Binding CreateTime , StringFormat=\{0:yyyy-MM-dd HH:mm:ss\}}" FontSize="14"/>
                                    </StackPanel>
                                </GroupBox.Header>
                                
                                <StackPanel Orientation="Vertical">
                                    <StackPanel Orientation="Horizontal">
                                        <TextBlock Margin="3" VerticalAlignment="Center" Text="用户名称"/>
                                        <TextBox Margin="3" Name="tbName" VerticalAlignment="Center" Text="{Binding Name}" IsReadOnly="True" Width="80"/>
                                        <TextBlock Margin="3" VerticalAlignment="Center" Text="用户昵称"/>
                                        <TextBox Margin="3" VerticalAlignment="Center" Text="{Binding NickName}" IsReadOnly="True" Width="80"/>
                                        <TextBlock Margin="3" VerticalAlignment="Center" Text="真实姓名" />
                                        <TextBox Margin="3" VerticalAlignment="Center" Text="{Binding RealName}" IsReadOnly="True" Width="80"/>
                                        <TextBlock Margin="3" VerticalAlignment="Center" Text="手机号码"/>
                                        <TextBox Margin="3" VerticalAlignment="Center" Text="{Binding PhoneMobile}" IsReadOnly="True" Width="150"/>
                                        <TextBlock Margin="3" VerticalAlignment="Center" Text="座机号码"/>
                                        <TextBox Margin="3" VerticalAlignment="Center" Text="{Binding Phone}" IsReadOnly="True" Width="150"/>
                                        <Button Name="btnStartPPCRM" VerticalAlignment="Center" Click="btnStartPPCRM_Click" Content="点击聊天" DataContext="{Binding}"/>
                                    </StackPanel>

                                    <StackPanel Orientation="Horizontal">
                                        <TextBlock Margin="3" VerticalAlignment="Center" Text="物流公司"/>
                                        <TextBox Margin="3" Name="tbDeliveryCompany" VerticalAlignment="Center" Text="{Binding DeliveryCompany}" Width="80"/>
                                        <TextBlock Margin="3" VerticalAlignment="Center" Text="物流单号"/>
                                        <TextBox Margin="3" Name="tbDeliveryNumber" VerticalAlignment="Center" Text="{Binding DeliveryNumber}" Width="80"/>
                                        <Button Margin="3" Name="btnQueryDelivery" Content="查询物流信息" VerticalAlignment="Center" Width="80" Click="btnQueryDelivery_Click"/>
                                        <Button Margin="3" Name="btnUpdateDelivery" Content="更新物流单号" VerticalAlignment="Center" Width="80" Click="btnUpdateDelivery_Click"/>
                                        <TextBlock Margin="3" VerticalAlignment="Center" Text="收获地址" DockPanel.Dock="Left" />
                                        <TextBox Margin="3" VerticalAlignment="Center" Text="{Binding Address}" IsReadOnly="True" AcceptsReturn="True" MinWidth="350"/>
                                    </StackPanel>
                                    
                                    <Grid >
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition Height="Auto"/>
                                        </Grid.RowDefinitions>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="*"/>
                                        </Grid.ColumnDefinitions>
                                        <TextBlock Grid.Column="0" Grid.Row="0" Text="买家描述" Margin="3" VerticalAlignment="Center"/>
                                        <TextBox Grid.Column="1" Grid.Row="0"  IsReadOnly="True" Margin="3" Text="{Binding BuyerComment}" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" AcceptsReturn="True" TextWrapping="Wrap" />
                                        <TextBlock Grid.Column="0" Grid.Row="1"  Text="卖家描述" Margin="3" VerticalAlignment="Center"/>
                                        <TextBox Grid.Column="1" Grid.Row="1"  IsReadOnly="True" Margin="3" Text="{Binding SellerComment}" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" AcceptsReturn="True" TextWrapping="Wrap" />
                                    </Grid>
                                    <ListBox MinHeight="30" ItemsSource="{Binding Path=Items}" Margin="6"
                                     Name="lstItems" 
                                     ScrollViewer.HorizontalScrollBarVisibility="Disabled" 
                                     ScrollViewer.VerticalScrollBarVisibility="Disabled" 
                                     SelectionMode="Extended" >
                                        <ListBox.ItemContainerStyle>
                                            <Style TargetType="ListBoxItem">
                                                <Setter Property="Template">
                                                    <Setter.Value>
                                                        <ControlTemplate TargetType="ListBoxItem">
                                                            <Grid >
                                                                <Grid.RowDefinitions>
                                                                    <RowDefinition Height="Auto"/>
                                                                    <RowDefinition Height="Auto"/>
                                                                </Grid.RowDefinitions>
                                                                <Image Source="{Binding Image,Converter={StaticResource ResourceKey=orderimageconvert}}" Grid.Row="0" Width="120" Height="120" Stretch="Fill"/>
                                                                <StackPanel Margin="3" Orientation="Horizontal" Grid.Row="1">
                                                                    <TextBlock Margin="3" VerticalAlignment="Center" Text="{Binding InternalName}"/>
                                                                    <TextBlock Margin="3" VerticalAlignment="Center" Text="{Binding Color}"/>
                                                                    <TextBlock Margin="3" VerticalAlignment="Center" Text="{Binding Size}"/>
                                                                </StackPanel>
                                                            </Grid>
                                                        </ControlTemplate>
                                                    </Setter.Value>
                                                </Setter>
                                            </Style>
                                        </ListBox.ItemContainerStyle>
                                        <ListBox.ItemsPanel>
                                            <ItemsPanelTemplate>
                                                <WrapPanel/>
                                            </ItemsPanelTemplate>
                                        </ListBox.ItemsPanel>
                                    </ListBox>
                                </StackPanel>
                            </GroupBox>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </ListBox.ItemContainerStyle>
    </ListBox>

</UserControl>
